<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../000-assets/cdn/axios.min.js"></script>
</head>

<body>
    <script>
        function* gen() {
            let res1 = yield axios.get('data.json');
            console.log('第一次请求的数据:', res1);
            let res2 = yield axios.get('data.json');
            console.log('第二次请求的数据:', res2);
        }

        let g = gen();
        // 这么一看，这不还是回调地狱么。。所以后来被async await取代了
        g.next().value.then(res => {
            g.next(res).value.then(res => {
                g.next(res);
            })
        })
    </script>
</body>

</html>